package cn.shuangliang.contract.model;

import org.hibernate.validator.constraints.Length;
import org.springframework.format.annotation.DateTimeFormat;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class Contract {
    private Long id;

    //byte[]
    private String hetongpic;//合同的文本的复印件，存地址


    @NotBlank(message = "合同号不能为空！")
    @NotNull(message = "合同号不能为空！")
    @Length(max = 30,min = 4,message = "长度必须在4-30之间！@")
    private String contractno;


    //Date->String


    private Date ctime;

    @NotBlank(message = "单据不能为空！")
    private String billno;

    @NotBlank(message = "经手人不能为空！")
    private String marker;

    private Boolean isall;


    //@Pattern(regexp="1\\d{10}")
    private String seller;

    //Date->String
    private Date cdate;

    private List<Contractitem> items=new ArrayList<>();

    private List<Contractitem> historys=new ArrayList<>();

    public Contract(){}

    public Contract(String contractno, Date ctime, String billno, String marker, String seller) {
        this.contractno = contractno;
        this.ctime = ctime;
        this.billno = billno;
        this.marker = marker;
        this.seller = seller;

    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getHetongpic() {
        return hetongpic;
    }

    public void setHetongpic(String hetongpic) {
        this.hetongpic = hetongpic;
    }

    public List<Contractitem> getHistorys() {
        return historys;
    }

    public void setHistorys(List<Contractitem> historys) {
        this.historys = historys;
    }

    public String getContractno() {
        return contractno;
    }

    public void setContractno(String contractno) {
        this.contractno = contractno == null ? null : contractno.trim();
    }

    public Date getCtime() {
        return ctime;
    }

    public void setCtime(Date ctime) {
        this.ctime = ctime;
    }

    public String getBillno() {
        return billno;
    }

    public void setBillno(String billno) {
        this.billno = billno == null ? null : billno.trim();
    }

    public String getMarker() {
        return marker;
    }

    public void setMarker(String marker) {
        this.marker = marker == null ? null : marker.trim();
    }

    public Boolean getIsall() {
        return isall;
    }

    public void setIsall(Boolean isall) {
        this.isall = isall;
    }

    public String getSeller() {
        return seller;
    }

    public void setSeller(String seller) {
        this.seller = seller == null ? null : seller.trim();
    }

    public Date getCdate() {
        return cdate;
    }

    public void setCdate(Date cdate) {
        this.cdate = cdate;
    }

    public List<Contractitem> getItems() {
        return items;
    }

    public void setItems(List<Contractitem> items) {
        this.items = items;
    }

    @Override
    public String toString() {
        return "Contract{" +
                "id=" + id +
                ", contractno='" + contractno + '\'' +
                ", ctime=" + ctime +
                ", billno='" + billno + '\'' +
                ", marker='" + marker + '\'' +
                ", isall=" + isall +
                ", seller='" + seller + '\'' +
                ", cdate=" + cdate +
                '}';
    }
}